import http from './http.js'

// 登录接口
export const login = (data) => {
	return http("/web/users/login", data, "POST")
}

// 注册接口
export const register = (data) => {
	return http("/web/users/signup", data, "POST")
}

// 获取文章列表数据
export const getArticles = (data) => {
	return http(
		`/web/articles?title=${data.title || ''}&categoryId=${data.categoryId || ''}&currentPage=${data.currentPage || ''}&pageSize=${data.pageSize || ''}`
	)
}

// 获取精选技术文章
export const getAbilityArticle = (data) => {
	return http(`/web/articles/ability`, data, "POST")
}

// 获取精选生活文章
export const getLifeArticle = (data) => {
	return http(`/web/articles/life`, data, "POST")
}

// 获取点赞量最多的文章
export const getHotArticle = (data) => {
	return http(`/web/articles/likes?currentPage=${data.currentPage || ''}&pageSize=${data.pageSize || ''}`)
}

// 查询用户详情数据
export const getUserDetail = (data) => {
	return http(`/web/is_me/user_art/0?currentPage=${data.currentPage || ''}&pageSize=${data.pageSize || ''}`)
}

// 查询用户点赞数据
export const getUserLike = (data) => {
	return http(`/web/is_me/likes?currentPage=${data.currentPage || ''}&pageSize=${data.pageSize || ''}`)
}

// 查询用户收藏数据
export const getUserCollect = (data) => {
	return http(`/web/is_me/collect?currentPage=${data.currentPage || ''}&pageSize=${data.pageSize || ''}`)
}


// 查询博客详情数据
export const getDetailArticle = (data) => {
	return http(`/web/articles/${data}`)
}

// 根据title查询分类数据
export const getFenleiDetail = (data) => {
	return http(
		`/web/category?title=${data.title || ''}&currentPage=${data.currentPage || ''}&pageSize=${data.pageSize}`
		)
}

// 修改密码
export const updatePassword = (data) => {
	return http("/web/is_me/updatePassword", data, "PATCH")
}